package com.bob.idea.action;

import com.bob.common.DataStore;
import com.bob.common.GitPatchGenerator;
import com.bob.common.GitRepository;
import com.bob.common.PomReader;
import com.bob.common.resources.ResourcesExec;
import com.bob.common.resources.exec.DefaultExec;
import com.bob.common.utils.FileUtil;
import com.bob.idea.common.Constant;
import com.bob.idea.gui.MainFrame;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class UpgradeMojo {
    public static void exec(String basePath){
        // 设置项目根目录
        DataStore.getDataStore().setRootDir(basePath);

        // 初始化文件映射
        ResourcesExec resourcesExec = new DefaultExec();
            resourcesExec.initResources( new ArrayList<>());
        List<String> visionNumbers =(List<String>) DataStore.getDataStore().getData().get(Constant.CACHE_KEY_visionNumbers);

        try {
            // 扫描 pom 项目文件夹
            new PomReader().initPomDataStore(basePath);
            GitRepository gitRepository = new GitRepository(DataStore.getDataStore().getRootDir());
            //  根据 commitId 查找git log
            gitRepository.scanLog(visionNumbers.toArray(new String [visionNumbers.size()]));
            // project diff 文件清单
            gitRepository.getDiffItems();
        } catch (IOException | org.eclipse.jgit.api.errors.GitAPIException  e) {
            e.printStackTrace();
        }

    }
}
